#ifndef SAVECURVEDATA_H
#define SAVECURVEDATA_H

#include <QObject>
#include <QFile>
#include <QTimer>

class Curve;
class SaveCurveData : public QObject
{
    Q_OBJECT

public:
    SaveCurveData(Curve &curve, QObject *parent = nullptr);
    ~SaveCurveData();

    void setPeriod(int period);
    int getPeriod();

    void setFileName(const QString &fileName);
    QString getFileName();

    void addData(const QString &data);
    void addData(const QList<QString> &data);

    void start();
    void stop();

    bool getStatus() const;

    void save();

public slots:
    void onTimeout();

signals:
    void changeStatus(bool isStart);

private:
    QList<QString> m_datas;

    int m_period = 1000; // ms
    QTimer *m_timer = nullptr;

    QString m_fileName;
    QFile m_file;

    Curve *m_curve;
};

#endif // SAVECURVEDATA_H
